home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / LIFE_SIM / VERSION_ / HANDLEMO.C < prev    next >
Text File  |  1992-03-12  |  2KB  |  111 lines

  1. /* Cell Proj 1.0 */
  2.  
  3. #include "MacProto.h"
  4. #include "Cell_Proto.h"
  5. #include "Cell_Definitions.h"
  6. #include "Cell_Variables.h"
  7.  
  8. HandleMouseDown()
  9. {
  10.     WindowPtr        whichWindow;
  11.     short            thePart;
  12.     int                theControlPart;
  13.     long int        menuChoice, windSize;
  14.     ControlHandle    controlHitHandle;
  15.     int                hitControl, oldValue, currentValue;
  16.     
  17.     thePart = FindWindow( gTheEvent.where, &whichWindow );
  18.     switch ( thePart )
  19.     {
  20.         case inMenuBar:
  21.             menuChoice = MenuSelect( gTheEvent.where );
  22.             HandleMenuChoice( menuChoice );
  23.             break;
  24.         case inSysWindow:
  25.             SystemClick( &gTheEvent, whichWindow );
  26.             break;
  27.         case inDrag:
  28.             DragWindow( whichWindow, gTheEvent.where, &gDragRect );
  29.             SetPort( whichWindow );
  30.             break;
  31.         case inGoAway:
  32.             HideWindow( whichWindow );
  33.             break;
  34.         case inContent:
  35.             SelectWindow( whichWindow );
  36.             break;
  37.         case inGrow:
  38.             break;
  39.     }
  40. }
  41.  
  42. HandleMenuChoice( menuChoice )
  43. long int    menuChoice;
  44. {
  45.     int        theMenu;
  46.     int        theItem;
  47.     
  48.     if ( menuChoice != 0 )
  49.     {
  50.         theMenu = HiWord( menuChoice );
  51.         theItem = LoWord( menuChoice );
  52.         switch ( theMenu )
  53.         {
  54.             case APPLE_MENU_ID:
  55.                 HandleAppleChoice( theItem );
  56.                 break;
  57.             case FILE_MENU_ID:
  58.                 HandleFileChoice( theItem );
  59.                 break;
  60.         }
  61.         HiliteMenu( 0 );
  62.     }
  63. }
  64.  
  65. HandleAppleChoice( theItem )
  66. int        theItem;
  67. {
  68.     Str255        accName;
  69.     int            accNumber;
  70.     short int    itemNumber;
  71.  
  72.     switch ( theItem )
  73.     {
  74.         case ABOUT_ITEM:
  75.             NoteAlert( ABOUT_ALERT, NIL_POINTER );
  76.             break;
  77.         default:
  78.             GetItem( gAppleMenu, theItem, accName );
  79.             accNumber = OpenDeskAcc( accName );
  80.             break;
  81.     }
  82. }
  83.  
  84. HandleFileChoice( theItem )
  85. int        theItem;
  86. {
  87.     switch( theItem )
  88.     {
  89.         case SHOW_ALL_WINDOW_ITEM:
  90.             ShowWindow( gCellWindow );
  91.             ShowWindow( gCellInfoDialog );
  92.             DrawDialog( gCellInfoDialog );
  93.             SelectWindow( gCellInfoDialog );
  94.             break;
  95.         case QUIT_ITEM:
  96.             gDone = TRUE;
  97.             break;
  98.     }
  99. }
  100.  
  101. ResizeWindow( whichWindow, windSize )
  102. long            windSize;
  103. WindowPtr        whichWindow;
  104. {
  105.     GrafPtr            oldPort;
  106.  
  107.     GetPort( &oldPort );
  108.     SetPort( whichWindow );
  109.     SizeWindow( whichWindow, 170, HiWord( windSize ), NORMAL_UPDATES );
  110.     SetPort( oldPort );
  111. }